package com.maxlen.member.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.maxlen.common.constant.AuthServerConstant;
import com.maxlen.common.utils.PageUtils;
import com.maxlen.common.utils.R;
import com.maxlen.common.utils.ResultCode;
import com.maxlen.member.entity.MemberEntity;
import com.maxlen.member.entity.vo.LoginVO;
import com.maxlen.member.entity.vo.UserRegisterVO;
import com.maxlen.member.feign.CouponFeignService;
import com.maxlen.member.service.MemberService;
import com.maxlen.member.utils.HttpRequest;
import org.apache.http.HttpResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;


/**
 * 会员
 *
 * @author MaxLen
 * @email MaxLen@gmail.com
 * @date 2022-10-27 10:49:30
 */
@RestController
@RequestMapping("member/member")
public class MemberController {
    @Autowired
    private MemberService memberService;

    @Autowired
    private CouponFeignService couponFeignService;

    /**
     * 远程调用：获取所有的会员id和会员名称
     * @return
     */
    @GetMapping("/getMemberByCouponPublish")
    public R getMemberByCouponPublish(){
        return memberService.getMemberByCouponPublish();
    }

    /**
     * 远程调用：根据用户 id 获取 Integration
     * @param memberId
     * @return
     */
    @GetMapping("/getMemberIntegration/{memberId}")
    public R getMemberIntegration(@PathVariable("memberId") Long memberId){
        return memberService.getMemberIntegration(memberId);
    }

    @RequestMapping("/coupon/list")
    public R couponList(){
        MemberEntity memberEntity = new MemberEntity();
        memberEntity.setNickname("MaxLen");
        R couponList = couponFeignService.getCouponList();
        return R.ok().put("name", memberEntity).put("couponList", couponList.get("couponList"));
    }

}
